<?php
require_once 'classes/View.php';

session_start();

global $pageOn;
$pageOn = basename($_SERVER['PHP_SELF']);
if (!isset($_SESSION['user']))
{
	header('Location: index.php');
}
else
{
	/*View*/ $view = new View();
	if (count($_REQUEST))
	{
		$_SESSION['user']->setPassword($_REQUEST['password']);
		$_SESSION['user']->setFirstName($_REQUEST['first_name']);
		$_SESSION['user']->setLastName($_REQUEST['last_name']);
		$_SESSION['user']->setEMail($_REQUEST['e_mail']);
		$error = $_SESSION['user']->edit();
		if($error == "")
		{
			$view->data['notification'] = 'Edit successful';
		}
		else
		{
			$view->data['error'] = $error;
		}
	}
	$view->display('profile');
}
?>